package com.atguigu.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;
/*
* 此类为连接工厂，创建信道的工具类，会返回一个信道
* */
public class RabbitMqUtils {

    /*得到一个连接的信道(channel)*/
    public static Channel getChannel() throws IOException, TimeoutException {
        /*创建一个连接工厂*/
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.161.128");
        factory.setUsername("admin");
        factory.setPassword("admin");
        Connection connection = factory.newConnection();
        Channel channel = (Channel) connection.createChannel();
        return channel;
    }

}